from rest_framework.generics import ListAPIView
from rest_framework.permissions import IsAdminUser
from rest_framework.viewsets import ModelViewSet
from goods.models import SpecificationOption, SPUSpecification
from meiduo_admin.serializers.options import OptionSerialzier, OptionSpecificationSerializer
from meiduo_admin.utils import PageNum


class OptionsView(ModelViewSet):
    # 指定序列化器
    serializer_class = OptionSerialzier
    # 指定查询集
    queryset = SpecificationOption.objects.all()
    # 指定分页器
    pagination_class = PageNum
    # 指定权限
    permission_classes = [IsAdminUser]

class OptionSimple(ListAPIView):
    """
        获取规格信息
    """
    serializer_class = OptionSpecificationSerializer
    queryset = SPUSpecification.objects.all()